home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / bchelp10.zip / TI637.ASC < prev    next >
Text File  |  1991-09-11  |  3KB  |  133 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Borland C                              NUMBER  :  637
  9.   VERSION  :  2.0
  10.        OS  :  PC DOS
  11.      DATE  :  September 11, 1991                       PAGE  :  1/2
  12.  
  13.     TITLE  :  Fix for BCWDEMO Line Drawing Example
  14.  
  15.  
  16.  
  17.  
  18.   BCWDEMO does not draw lines  appropriately  if  drawn  from lower
  19.   right  to  upper  left.  The  replacement  code  below fixes  the
  20.   problem.
  21.  
  22.   Basically,  the  code   ordering   must  be  changed  and  a  new
  23.   conditional statement  substituted  for  the  old.  Below  code--
  24.   replacement function--fixes the line drawing problem.
  25.  
  26.   /****************************************************************
  27.    * function DoLButtonUp
  28.    *    When the left mouse button is released, this routine
  29.    *    allows other windows to receive mouse messages and saves
  30.    *    the position of the mouse as the other corner of a bounding
  31.    *    rectangle for the shape.
  32.    ***************************************************************/
  33.  
  34.   void DoLButtonUp(HWND hWnd, LONG lParam)
  35.   {
  36.       ReleaseCapture();
  37.  
  38.       /*
  39.        * If the origin of the line has changed, it should be drawn
  40.        * from upper right to lower left and therefore has negative
  41.        * slope.  Otherwise it will have positive slope.
  42.        */
  43.  
  44.       if (CurrentShape == LINE)
  45.         thisShape[CurrentPoint].Slope =
  46.         (thisShape[CurrentPoint].Points.left < LOWORD(lParam) &&
  47.          thisShape[CurrentPoint].Points.top < HIWORD(lParam)) ||
  48.         (thisShape[CurrentPoint].Points.left > LOWORD(lParam) &&
  49.          thisShape[CurrentPoint].Points.top > HIWORD(lParam))
  50.          ? 1 : -1;
  51.  
  52.       /*
  53.        * For rectangles to work with the IntersectRect function,
  54.        * they must be stored as left, top, right, bottom.
  55.        */
  56.       SetRect(&thisShape[CurrentPoint].Points,
  57.               min(thisShape[CurrentPoint].Points.left,
  58.               LOWORD(lParam)),
  59.               min(thisShape[CurrentPoint].Points.top,
  60.               HIWORD(lParam)),
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Borland C                              NUMBER  :  637
  75.   VERSION  :  2.0
  76.        OS  :  PC DOS
  77.      DATE  :  September 11, 1991                       PAGE  :  2/2
  78.  
  79.     TITLE  :  Fix for BCWDEMO Line Drawing Example
  80.  
  81.  
  82.  
  83.  
  84.               max(thisShape[CurrentPoint].Points.left,
  85.               LOWORD(lParam)),
  86.               max(thisShape[CurrentPoint].Points.top,
  87.               HIWORD(lParam)));
  88.       /*
  89.        * Mark this region on the window as
  90.        * needing redrawing and force an update.
  91.        */
  92.       InvalidateRect(hWnd, &thisShape[CurrentPoint].Points, 0);
  93.       UpdateWindow(hWnd);
  94.       mouseDown = 0;
  95.       oldx = -1;
  96.       oldy = -1;
  97.   }
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.